#===============================================================================
# Koro Business Environment
# Copyright (C) 2008  Antonio Corroppoli
#
#This file is part of Koro BE.
# 
# Koro BE is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# 
# Koro BE is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with Koro BE; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
#===============================================================================

'''
Created on 20/ago/2011

@author: antstud
'''
import wx
from koro.ui.wxgui.widgets.dialogs import Lookup
from koro.modules.lookup.ui import panel

#===============================================================================
# LookupClienti
#===============================================================================
class LookupClienti(Lookup):
    def __init__(self,*args,**kwargs):
        Lookup.__init__(self,header='Seleziona il Cliente',*args,**kwargs)
#        self.SetTitle('Lookup Clienti')
        self.set_panel(panel.LookupClientiPanel(self))
    
    def _set_return_object(self,code):
        observer=wx.GetApp().get_observer()
        observer.set_context('CLIENTI')
        self._return_object=observer.get_object(ID=int(code))
            
        

#===============================================================================
# LookupFornitori
#===============================================================================
class LookupFornitori(Lookup):
    def __init__(self,*args,**kwargs):
        Lookup.__init__(self,header='Seleziona il Fornitore',*args,**kwargs)
#        self.SetTitle('Lookup Fornitori')
        self.set_panel(panel.LookupFornitoriPanel(self))
    
    def _set_return_object(self,code):
        observer=wx.GetApp().get_observer()
        observer.set_context('FORNITORI')
        self._return_object=observer.get_object(ID=code)


#===============================================================================
# LookupProdotti
#===============================================================================
class LookupProdotti(Lookup):##TODO:sistemare header    
    def __init__(self,*args,**kwargs):
        Lookup.__init__(self,header='',*args,**kwargs)
        title='Seleziona Prodotto'
        if self.filter is not None:
            title+=' - {0}'.format(self.filter.ragione_sociale)
        self.set_header(title)
        self.set_panel(panel.LookupProdottiPanel(self,fornitore=self.filter))
        self.get_panel().reset_focus()
    
    def _set_return_object(self,code):
        observer=wx.GetApp().get_observer()
        observer.set_context('PRODOTTI')
        self._return_object=observer.get_object(ID=code) 
